package com.example.administrator.asdasd;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/3/31.
 */
public class dan_hz extends AppCompatActivity {
    private Button hd_btn1;
    private TextView cd_tt1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.huodan);

        cd_tt1 = (TextView)findViewById(R.id.top2_end_hz);
        cd_tt1.setText("运单信息");

        SQLdm s = new SQLdm();
        SQLiteDatabase db = s.openDatabase(getApplicationContext());
        Cursor c = db.rawQuery("select * from hztb where hzs=?", new String[]{"2"});
        List<ItemBean> itemBeanList = new ArrayList<>();
        if (c != null) {
            while (c.moveToNext()) {
                itemBeanList.add(new ItemBean(
                        "货主 ："+c.getString(c.getColumnIndex("name")),
                        "载重 ："+c.getString(c.getColumnIndex("max"))+"吨",
                        c.getString(c.getColumnIndex("weizhi")) +"  -- "+c.getString(c.getColumnIndex("aim")),
                        "tell:"+c.getString(c.getColumnIndex("num"))
                ));
            }

        }
        c.close();
        db.close();
        ListView listView = (ListView) findViewById(R.id.listView3);
        listView.setAdapter(new MyAdapter(this.getApplication(), itemBeanList));
        hd_btn1 = (Button) findViewById(R.id.top2_btn1);
        hd_btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }
}
